package cn.parus.common.utils;

import java.util.Random;
/**
 * @Author: Axel
 * @Description: TODO
 **/
public class ExtractCodeUtils {
    public ExtractCodeUtils(){}; // 防止实例化

    private static final String CHARACTER_POOL = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final int CODE_LENGTH = 4;
    private static final Random RANDOM = new Random();

    /**
     * 生成4位混合数字和字母的提取码
     * @return
     */
    public static String generateExtractCode() {
        StringBuilder codeBuilder = new StringBuilder();
        for (int i = 0; i < CODE_LENGTH; i++) {
            int randomIndex = RANDOM.nextInt(CHARACTER_POOL.length());
            codeBuilder.append(CHARACTER_POOL.charAt(randomIndex));
        }
        return codeBuilder.toString();
    }
}
